/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sessionFacades;

import businessObjects.Cliente;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import services.ClienteServicesLocal;

/**
 *
 * @author williamprado
 */
@Stateless
public class ClienteFacade implements ClienteFacadeRemote{

    /*@PersistenceContext(unitName = "Adz-ejbPU")
    private EntityManager em;*/

    @EJB
    private ClienteServicesLocal clienteServices;

    public void registrarCliente(Cliente cliente) {
            clienteServices.nuevoCliente(cliente);
    }

    public Cliente login(String login, String pass){
        Cliente cl = clienteServices.login(login, pass);
        return cl;
    }

    public Cliente consultarCliente(String login) {
        Cliente cliente = clienteServices.consultarCliente(login);
        return cliente;
    }

    public void actualizarCliente(Cliente cliente) {
            clienteServices.actualizarCliente(cliente);
    }

    public void eliminarCliente(String login) {
            clienteServices.eliminarCliente(login);
    }

    /*public void create(Cliente cliente) {
        em.persist(cliente);
    }

    public void edit(Cliente cliente) {
        em.merge(cliente);
    }

    public void remove(Cliente cliente) {
        em.remove(em.merge(cliente));
    }

    public Cliente find(Object id) {
        return em.find(Cliente.class, id);
    }

    public List<Cliente> findAll() {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        cq.select(cq.from(Cliente.class));
        return em.createQuery(cq).getResultList();
    }

    public List<Cliente> findRange(int[] range) {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        cq.select(cq.from(Cliente.class));
        Query q = em.createQuery(cq);
        q.setMaxResults(range[1] - range[0]);
        q.setFirstResult(range[0]);
        return q.getResultList();
    }

    public int count() {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        Root<Cliente> rt = cq.from(Cliente.class);
        cq.select(em.getCriteriaBuilder().count(rt));
        Query q = em.createQuery(cq);
        return ((Long) q.getSingleResult()).intValue();
    }*/

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method" or "Web Service > Add Operation")



}
